const state = {
  teacher: new Array(),
  teacherSelectModel: ''
}
const mutations = {
  SET_TEACHER: (state, data) => {
    try {
      for (let i = 0; i < state.teacher.length; i++) {
        if (state.teacher[i].id == data.id) {
            state.teacher.splice(i, 1)
        }
      }
    } catch (e) {
    }
      state.teacher.push(data)
  },
  SET_TEACHER_SELECT_MODEL: (state, data) => {
      state.teacherSelectModel=data
  },
  CLEAN_TEACHER: (state) => {
    state.teacher = new Array()
    state.teacherSelectModel=''
  },
  CLEAN_TEACHER_DATA: (state) => {
    state.teacher = new Array()
  }
}

const actions = {

  setTeacher({ commit }, data) {
    commit('SET_TEACHER', data)
  },
  // 设置代理选择模式
  setTeacherSelectModel({ commit }, data) {
    commit('SET_TEACHER_SELECT_MODEL', data)
  },
  // 清空代理-全部清空
  cleanTeacher({ commit }) {
    commit('CLEAN_TEACHER')
  },
  // 清空代理-选中数据
  cleanTeacherData({ commit }) {
    commit('CLEAN_TEACHER_DATA')
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

